package com.samsung.common.exception;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerExceptionResolver;
import org.springframework.web.servlet.ModelAndView;

/**
 * 
 *	@ClassName: MyHandlerExceptionResolver
 *	@Description: 异常处理
 *	@author pu.huang
 *	@date 2015年4月27日 下午3:07:09
 *
 */
@Component
public class MyHandlerExceptionResolver implements HandlerExceptionResolver {

	@Override
	public ModelAndView resolveException(HttpServletRequest request,
			HttpServletResponse response, Object handler, Exception ex) {

		Log logicLog = LogFactory.getLog("logic");
		logicLog.error(ex);
		
		ex.printStackTrace();
		
		ModelAndView mav = new ModelAndView("error/404");
		mav.addObject("msg", ex.getMessage());

		return mav;
	}

}